package com.edu.service.impl;

import com.edu.bean.User;
import com.edu.mapper.UserMapper;
import com.edu.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public List<User> getAllUser() {
        List<User> users = userMapper.selectAllUser();
        return users;
    }

    @Override
    public void addUser(User user) {
        userMapper.addUser(user);
    }

    @Override
    public void deleteUser(int userId) {
        userMapper.deleteUser(userId);
    }

    @Override
    public User getUserById(int userId) {
        User user = userMapper.selectUserById(userId);
        return user;
    }

    @Override
    public void changeUser(User user) {
        userMapper.updateUser(user);
    }

    @Override
    public User getUserByNamePass(User user) {
        User user1 = userMapper.selectUserByNamePass(user);
        return user1;
    }

    @Override
    public User getUserByName(String userName) {
        User user = userMapper.selectUserByName(userName);
        return user;
    }

}
